﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PathUtil 
{
    //Asset目录
    public static readonly string AssetPath = Application.dataPath;

    //需要打AB包资源的目录
    public static readonly string BundleResoucePath = AssetPath + "/BundleResource/";

    //Bundle输出目录
    public static readonly string BundleOutPath = Application.streamingAssetsPath;

    //只读根目录
    public static readonly string ReadPath = Application.streamingAssetsPath;

    //Lua文件路径
    public static readonly string LuaPath = "Assets/BundleResource/Lua";

    //bundle资源路径
    public static string ABundleResourcePath

    {
        get
        {
            //if (AppConst.GameMode == GameMode.UpdateMode)
            //    return ReadWritePath;
            return ReadPath;
        }
    }


    /// <summary>
    /// 获取Unity的相对路径
    /// </summary>
    /// <param name="_path"></param>
    /// <returns></returns>
    public static string GetUnityPath(string _path)
    {
        if (string.IsNullOrEmpty(_path))
            return string.Empty;
        return _path.Substring(_path.IndexOf("Assets", System.StringComparison.CurrentCulture)); //从Assets开始索引
    }


    /// <summary>
    /// 获取标准路径
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    public static string GetStandardPath(string path)
    {
        if (string.IsNullOrEmpty(path))
            return string.Empty;
        return path.Trim().Replace("\\", "/");
    }


    //资源路径规划
    //便于维护

    //Lua脚本
    public static string GetLuaPath(string name)
    {
        return string.Format("Assets/BundleResource/Lua/{0}.bytes", name);
    }

    //UI预制体
    public static string GetUIPath(string name)
    {
        return string.Format("Assets/BundleResource/UI/Prefabs/{0}.prefab", name);
    }


    public static string GetMusicPath(string name)
    {
        return string.Format("Assets/BundleResource/Audio/Music/{0}", name);
    }

    public static string GetSoundPath(string name)
    {
        return string.Format("Assets/BundleResource/Audio/Sound/{0}", name);
    }

    public static string GetEffectPath(string name)
    {
        return string.Format("Assets/BundleResource/Effect/Prefabs/{0}.prefab", name);
    }

    public static string GetModelPath(string name)
    {
        return string.Format("Assets/BundleResource/Model/Prefabs/{0}.prefab", name);
    }

    public static string GetSpritePath(string name)
    {
        return string.Format("Assets/BundleResource/Sprites/{0}", name);
    }

    public static string GetScenePath(string name)
    {
        return string.Format("Assets/BundleResource/Scene/{0}.unity", name);
    }



}
